<?php

namespace App\Http\Controllers\OSS;

use App\Http\Controllers\BaseController;
use App\Http\Service\OSSClient\QiniuyunOSSClientService;
use App\Jobs\liveRecordFileDealWithTask;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class OSSController extends BaseController {

    public function __construct() {
        parent::__construct();
    }

    public function uploadEnd(Request $request) {
        $input = $request->all();
        Log::info('upload end');
        Log::info(json_encode($input));
    }

    public function uploadFile(Request $request) {
        $filePath = $request['filePath'];
        $fileName = $request['fileName'];
        $config = [
            "key" => $fileName,
            "filePath" => $filePath
        ];

//        $clientService = new QiniuyunOSSClientService();
//        $clientService->uploadFile($config['key'],$config['filePath'], true);
        liveRecordFileDealWithTask::dispatch($config)->onQueue('liveRecordFileDealWithTask');
        Log::info('add live record file deal with task: ' . trim($config['filePath'], ".flv"));
        return $this->returnJson([], "add live record file deal with task");
    }

}
